There are rectangles drawn on the plane.
Each rectangle has sides parallel to the coordinate axes and integer coordinates of vertices.
We define a block as follows:
each rectangle is a block,
if two distinct blocks have a common segment then they form the new block otherwise we say that these blocks are separate.
Examples
The rectangles in the first figure form two separate blocks.
The rectangles in the second form a single block
Task
Write a program that:
reads the number of rectangles and coordinates of their vertices from the standard input;
finds the number of separate blocks formed by the rectangles;
writes the result to the standard output.
Input
In the first line of the standard input there is an integer , ,
which is the number of rectangles.
In the following lines there are coordinates of rectangles.
Each rectangle is described by four numbers: coordinates of the bottom-left vertex
and coordinates of the top-right vertex.
All these coordinates are non-negative integers not greater than .
Output
In the first and only line of the standard output there should be written a single integer —
the number of separate blocks formed by the given rectangles.
W razie problemów technicznych ze Szkopułem, prosimy o kontakt mailowy pod adresem szkopul@fri.edu.pl.
Jeśli chciałbyś porozmawiać o zadaniach, rozwiązaniach lub problemach technicznych, odwiedź nasze serwery na Discordzie. Są one moderowane przez społeczność, ale członkowie zespołu wsparcia również aktywnie się tam udzielają.